<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
	<base href="<%=basePath%>">
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<!-- basic styles -->
	<link rel="stylesheet" href="assets/css/bootstrap.min.css" />
	<link rel="stylesheet" href="assets/css/chosen.css" />
	<link rel="stylesheet" href="assets/css/bootstrap-responsive.min.css" />
	<link rel="stylesheet" href="assets/css/font-awesome.min.css" />
	<!-- 下拉框 -->

</head>
<body>
	<form id="addForm" action="user/user_update.do" method="post">
		<div class="alert alert-info" style="margin-top:2px;margin-bottom:5px;height:40px;padding-top:10px;padding-bottom:10px;">
			<i class="icon-hand-right"></i>注意：标*的字段为必填项！
		</div>
		<table style="width:100%;border-collapse:separate;border-spacing:5px;">
			<tr>
				<td>用户昵称</td>
				<td><input type="text" name="name" value="${user.name }"  maxlength="12"  class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>用户密码</td>
				<td><input type="password" name="password" value="${user.password }"  maxlength="32"  class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>用户手机号</td>
				<td><input type="text" name="phone" id="phone" value="${user.phone }" onblur="phoneOnble();" maxlength="15" class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>用户邮箱</td>
				<td><input type="text" name="email" id ="email" value="${user.email }" maxlength="32" onblur="emailOnble()" class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>公司名称</td>
				<td><input type="text" name="company" maxlength="32" value="${user.company }"   class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<%-- <tr>
				<td>职位</td>
				<td><input type="text" name="position" maxlength="32" value="${user.position }"   class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr> --%>
			<tr>
				<td>用户类型</td>
				<td>	
				<select name="type" class="chosen-select col-xs-10 col-sm-5" >
						<c:forEach items="${typeUserList}" var="type">
						<option value="${type.id }" <c:if test="${user.type == type.id}">selected</c:if>>${type.name }</option>
						</c:forEach>
					</select>
				</td>
			</tr>
			<tr>
				<td>充值金额（元）</td>
				<td><input type="text" name="amount" maxlength="32" value="${user.amount }"   class="col-xs-10 col-sm-5"/></td>
			</tr>
			<tr>
				<td>单价/小时</td>
				<td><input type="text" name="singleConsumptionAmount" maxlength="32" value="${user.singleConsumptionAmount }"   class="col-xs-10 col-sm-5"/></td>
			</tr>
			<tr>
				<td>开始时间</td>
				<td><input type="text" name="startTime" value="${user.startTime }"   onclick="laydate()" class="laydate-icon"></td>
			</tr>
			<tr>
				<td>结束时间</td>
				<td><input type="text" name="endTime" maxlength="32" value="${user.endTime }"  onclick="laydate()"    class="laydate-icon"></td>
			</tr>
			<tr>
				<td>直播分辨率</td>
				<td>	
				<select name="video_resolution" class="chosen-select col-xs-10 col-sm-5" >
							<option value="1" <c:if test="${user.video_resolution==1 }">selected="selected"</c:if> >1080p</option>
							<option value="2" <c:if test="${user.video_resolution==2 }">selected="selected"</c:if> >720p</option>
							<option value="3" <c:if test="${user.video_resolution==3 }">selected="selected"</c:if> >640p</option>
							<option value="4" <c:if test="${user.video_resolution==4 }">selected="selected"</c:if> >360p</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>直播频道</td>
				<td>	
				<select name="channel_id" class="chosen-select col-xs-10 col-sm-5" >
						<c:forEach items="${getChannelPushList}" var="getChannelPushList">
						<option value="${getChannelPushList.id }" <c:if test="${user.channel_id == getChannelPushList.id}">selected</c:if>>${getChannelPushList.name }</option>
						</c:forEach>
					</select>
				</td>
			</tr>
			<tr>
				<td>录制功能</td>
				<td>	
				<select name="record" class="chosen-select col-xs-10 col-sm-5" >
							<option value="1" <c:if test="${user.record==1 }">selected="selected"</c:if> >未开启</option>
							<option value="2" <c:if test="${user.record==2 }">selected="selected"</c:if> >开启</option>
					</select>
				</td>
			</tr>
			<%-- <tr>
				<td>用户所属供应商</td>
				<td>	
				<select name="agentId" class="chosen-select col-xs-10 col-sm-5" >
						<c:forEach items="${agentList}" var="agent">
						<option value="${agent.id }" <c:if test="${user.agentId == agent.id}">selected</c:if>>${agent.companyName }</option>
						</c:forEach>
					</select>
				</td>
			</tr> --%>
			<tr>
				<td style="float:center;text-align:center;height:60px;" colspan="2">
					<input type="hidden" name="id" id="id" value="${user.id}" />
					<button type="button" onclick="saveBattery();" class="btn btn-info btn-sm "><i class="icon-edit bigger-120">&nbsp;&nbsp;</i>提交</button>
					<button type="button" onclick="top.Dialog.close();" class="btn btn-info btn-sm "><i class="icon-lightbulb bigger-120">&nbsp;&nbsp;</i>取消</button>
				</td>
			</tr>
		</table>
	</form>
	<script type="text/javascript" src="assets/js/jquery-1.10.2.min.js"></script>
	<!-- 引入 -->
	<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
	<!-- 下拉框 -->
	<script type="text/javascript" src="assets/js/chosen.jquery.min.js"></script>
	<!--提示框-->
	<script type="text/javascript" src="assets/js/jquery.tips.js"></script>
		<script type="text/javascript" src="assets/js/laydate/laydate.js"></script>
	<script type="text/javascript">
		$(function() {
			$("table tr").find("td:eq(0)").width(120);
			
		});
		 function phoneOnble(){
			 	var inp = document.getElementById("phone");
				var reg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
				var result = reg.test(inp.value);
				if (!result) {
					$("#phone").tips({
						side : 1,
						msg : '手机号格式不对，请重新输入!',
						bg : '#0099FF',
						time : 3
					});
					return false;
				}
			$.ajax({
				type : "POST",
				url : "user/edit_phone_check.do",
				data : {
					phone : $("input[name='phone']").val(),
					id : $("input[name='id']").val()
				},
				async : true,
				dataType : "text",
				success : function(data) {
					if (data == 1) {
						showTips($("input[name='phone']"), '手机号已存在');
						return false;
					}
				}
			});
		}
		function emailOnble() {
			var inp = document.getElementById("email");
			var reg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
			var result = reg.test(inp.value);
			if (!result) {
				$("#email").tips({
					side : 1,
					msg : '邮箱格式不对，请重新输入!',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
		}
		function saveBattery() {
			if ($("input[name='name']").val() == "") {
				showTips($("input[name='name']"), '请填写用户昵称！');
				return;
			}

			if ($("input[name='phone']").val() == "") {
				showTips($("input[name='phone']"), '请填写用户电话！');
				return;
			}
			if ($("input[name='password']").val() == "") {
				showTips($("input[name='password']"), '请填写用户密码!');
				return;
			}
			var phone = document.getElementById("phone");
			var reg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
			var result = reg.test(phone.value);
			if (!result) {
				$("#phone").tips({
					side : 1,
					msg : '手机号格式不对，请重新输入!',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
			/* var email = document.getElementById("email");
			var reg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
			var result = reg.test(email.value);
			if (!result) {
				$("#email").tips({
					side : 1,
					msg : '邮箱格式不对，请重新输入!',
					bg : '#0099FF',
					time : 3
				});
				return false;
			} */
		/* 	$.ajax({
				type : "POST",
				url : "user/edit_phone_check.do",
				data : {
					phone : $("input[name='phone']").val(),
					id : $("input[name='id']").val()
				},
				async : true,
				dataType : "text",
				success : function(data) {
					if (data == 1) {
						showTips($("input[name='phone']"), '手机号已存在');
						return false;
					} else */
						$("#addForm").submit();
			/* 	}
			});
 */
		};
		
		function showTips(obj,tips) {
			obj.tips({
				side:3,
	            msg:tips,
	            bg:'#e69138',
	            time:2
	        });
		}
	</script>
</body>
</html>